package com.foreknow.springboot_demo.controller;

import com.foreknow.springboot_demo.model.Admin;
import com.foreknow.springboot_demo.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController

public class AdminController {
    @Autowired
    private AdminService adminService;

    @GetMapping("/admin/login")
    public Admin login(Admin admin, ModelMap modelMap) {
        Admin admin1 = adminService.findByNameAndPassword(admin);
        modelMap.addAttribute("username",admin1.getUserName());
        modelMap.addAttribute("password",admin1.getPassword());
        return admin1;
    }
}
